<?php
// 连接数据库
$conn = new mysqli('localhost', 'root', '', 'your_database');

// 获取用户输入
$username = $_POST['username'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$email = $_POST['email'];

// 创建激活码（例如使用用户名的哈希）
$activation_code = md5($username . microtime());

// 存储到数据库
$stmt = $conn->prepare("INSERT INTO users (username, password, email, activation_code, created_at) VALUES (?, ?, ?, ?, NOW())");
$stmt->bind_param("ssss", $username, $password, $email, $activation_code);
$stmt->execute();

// 发送激活邮件
$activation_link = "http://127.0.0.1/verify?user=hw&code=ABCDEF" . urlencode($username) . "&code=" . $activation_code;
mail($email, "激活您的账户", "请点击以下链接激活您的账户：$activation_link");

echo "注册成功！请检查您的邮箱完成激活。";
?>